package com.lifetracker.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lifetracker.mapper.HabitMapper;
import com.lifetracker.model.Habit;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HabitService extends ServiceImpl<HabitMapper, Habit> {
    
    public List<Habit> getHabitsByUserId(Long userId) {
        return lambdaQuery().eq(Habit::getCreateId, userId).list();
    }
    
    public Habit createHabit(Habit habit) {
        save(habit);
        return habit;
    }
    
    public boolean updateHabit(Habit habit) {
        return updateById(habit);
    }
    
    public boolean deleteHabit(Long id) {
        return removeById(id);
    }
} 